package cn.yunyichina.provider.iface.entity;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
*
* 错误码定义<br>
* 00/50结尾：通用脱误码<br>
* 01/51结尾:参数错误码<br>
* 02/52结尾：值相关的错误码<br>
* 9300支付宝，9400通用消息，9500绑卡,9600订单<br>
*/
public class ErrorCodeDefine {

	/**
	 * 支付宝-通用错误码
	 */
	public static final String ALIPAY_COMMON = "9300"; 
	
	/**
	 * 支付宝-参数相关错误码
	 */
	public static final String ALIPAY_PARAM = "9301"; 
	
	/**
	 * 支付宝-值相关错误码
	 */
	public static final String ALIPAY_VALUE = "9302"; 
	
	
	/**
	 * 消息-通用错误码
	 */
	public static final String MESSAGE_COMMON = "9400"; 
	
	/**
	 * 消息-参数相关错误码
	 */
	public static final String MESSAGE_PARAM = "9401"; 
	
	/**
	 * 消息-值相关错误码
	 */
	public static final String MESSAGE_VALUE = "9402"; 
	
	/**
	 * 消息-找不到用户
	 */
	public static final String MESSAGE_NOT_USER = "9411"; 
	
	/**
	 * 消息-令牌
	 */
	public static final String MESSAGE_ACCESS_TOKEN= "9412"; 
	
	/**
	 * 消息-没有匹配的消息模板
	 */
	public static final String MESSAGE_NOT_EXIST_TEMPLATE = "9412"; 
	
	/**
	 * 消息-没有应用信息，比如appId
	 */
	public static final String MESSAGE_NOT_FIND_APP = "9414"; 
	
	/**
	 * 消息-没有用户openid信息
	 */
	public static final String MESSAGE_NOT_FIND_OPENID = "9415"; 
	/**
	 * 消息-找不到指定的消息重发规则
	 */
	public static final String MESSAGE_NOT_FIND_RESEND_RULE = "9416"; 
	
	
	/**
	 * 绑卡-通用错误码
	 */
	public static final String BIND_CARD_COMMON = "9500"; 
	/**
	 * 绑卡-参数相关错误码
	 */
	public static final String BIND_CARD_PARAM = "9501"; 
	
	/**
	 * 绑卡-值相关错误码
	 */
	public static final String BIND_CARD_VALUE = "9502"; 
	
	/**
	 * 绑卡-HIS患者信息建档失败
	 */
	public static final String BIND_CARD_CREATE_USER = "9503"; 
	
	/**
	 * 绑卡-已经绑定
	 */
	public static final String BIND_CARD_HAS_BINDED = "9504"; 
	
	/**
	 * 订单
	 */
	public static final String ORDER_COMMON = "9600"; 
	public static final String ORDER_PARAM = "9601"; 
	public static final String ORDER_VALUE = "9602"; 
	/**
	 * 生成订单编号无效
	 */
	public static final String ORDER_NO_INVALID = "9603"; 
	
	/**
	 * 当面付
	 */
	public static final String PAY_FACE_COMMON= "9630"; 
	
	/**
	 * 当面付，参数无效
	 */
	public static final String PAY_FACE_PARAM_INVALID= "9633"; 
	/**
	 * 当面付，支付失败
	 */
	public static final String PAY_FACE_PAY_FAIL= "9634"; 
	
	/**
	 * 智能导医
	 */
	public static final String GUIDE_COMMON= "9650"; 
	
	/**
	 * 智能导医
	 */
	public static final String GUIDE_VALUE= "9651"; 
	
	/**
	 * 智能导医,没有模板
	 */
	public static final String GUIDE_NOT_EXIST_TEMPLATE= "9652"; 
	
	
	public static DateFormat YYYYMMDDHHMMSS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public static DateFormat YYYYMMDDS = new SimpleDateFormat("yyyy-MM-dd");
	
	/**
	 * 获取异常的堆栈信息
	 * 此方法不会有异常抛出
	 * @param t
	 * @return 
	 */
	public static String getStackTrace(Throwable t) {
		try 
		{
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			t.printStackTrace(pw);
			pw.close();
			return sw.toString();
		}
		catch (Exception ex) {
			ex.printStackTrace();
		}
		return "";
	}
}